package com.hy.appbase.exception;

import com.hy.appbase.apiresult.ApiResult;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@ControllerAdvice
public class SysExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public ApiResult handleServiceException(BusinessException ex, HttpServletResponse response) {
        return ApiResult.FAIL(ex.getMessage());
    }
}
